import csv

student_dict = [
    {"name": "小千", "age": "19"},
    {"name": "小峰", "age": "20"},
]

fileheader = ["name", "age"]
with open('students.csv', 'w', encoding="utf-8-sig", newline='') as f:
    writer = csv.DictWriter(f, fileheader)
    writer.writeheader()
    writer.writerows(student_dict)